package com.hisense.ovcloud.mqtt.router.routers;

import com.hisense.ovcloud.commons.configs.validator.BaseRouterConfiguration;
import com.hisense.ovcloud.mqtt.router.service.CtlService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.RouterFunctions;
import org.springframework.web.reactive.function.server.ServerResponse;

import static org.springframework.web.reactive.function.server.RequestPredicates.path;
import static org.springframework.web.reactive.function.server.RouterFunctions.route;

@Configuration
public class RoutingConfiguration extends BaseRouterConfiguration {

    private final CtlService ctlServicel;

    public RoutingConfiguration(CtlService ctlServicel) {
        this.ctlServicel = ctlServicel;
    }

    @Bean
    public RouterFunction<ServerResponse> authRoutes() {
        return RouterFunctions.nest(path("/zc-mqtt-business/v1"),
                route()
                    .POST("/setCmd", ctlServicel::handleSetCmd)
                    .POST("/getDeviceInfo", ctlServicel::handleGetDeviceInfo)
                    .build());
    }
}

